#include<bits/stdc++.h>

using namespace std;

//实现偶检验的检测，奇校验只用改一下01即可(^~^)
int parity_check(const unsigned char *msg, const int msg_length)
{
    int count = 0;
    for (int i = 0; i < msg_length - 1; i++)
    {
        if (msg[i] != 0)
            count++;
    }
    return (count % 2) == msg[msg_length - 1] ? 1 : 0;
}

int main(){
    const unsigned char *msg = reinterpret_cast<const unsigned char *>("001101011");
    int msg_length = 9;
    cout << (parity_check(msg, msg_length) ? "校验通过" : "校验不通过");
}